package com.qf.mpswaggershiro.order.controller;

import com.qf.mpswaggershiro.order.entity.Orders;
import com.qf.mpswaggershiro.order.service.IOrdersService;
import com.qf.mpswaggershiro.vo.Vo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 订单  前端控制器
 * </p>
 *
 * @author cui
 * @since 2023-02-17
 */
@RestController
@RequestMapping("/order")
@CrossOrigin
@Slf4j
public class OrdersController {
    @Autowired
    IOrdersService ordersService;

    /**
     * 下单接口
     */
    @PostMapping("/add")
    public Vo add(String cids,@RequestBody Orders orders) throws Exception {

       Map<String,Object> data= ordersService.add(cids,orders);

       return Vo.ok(data);

    }

    /**
     * 返回订单支付状态接口
     */
    @GetMapping("/status/{oid}")
    public Vo status(@PathVariable String oid) throws Exception {
        //查询订单支付状态
    String data= ordersService.status(oid);
        //如果订单成功,返回字符串2
        return Vo.ok(data);
    }
}
